<?php

use yii\db\Migration;

class m180328_030052_create_wechat_payinfo extends Migration
{

    private function createDb(){
        $dbinfo = \Yii::$app->params['web_db'];
        $this->db =\Yii::createObject($dbinfo);
    }
    public function safeUp()
    {
        $this->createDb();
        $this->createTable('{{%wechat_payinfo}}',[
            'id' => $this->primaryKey()->notNull().' COMMENT \'自增id\'',
            'merchant_id' => $this->string(100)->defaultValue(null)->comment('商户id'),
            'key' => $this->string(255)->defaultValue(null)->comment('签名秘钥'),
            'cert_path' => $this->string(255)->defaultValue(null)->comment('证书存放路径'),
            'key_path' => $this->string(255)->defaultValue(null)->comment('秘钥存放路径'),
            'notify_url' => $this->string(255)->defaultValue(null)->comment('回调地址'),
            'device_info' => $this->string(255)->defaultValue(0)->comment('设备信息'),
            'created_at' => $this->integer()->defaultValue(0)->comment('创建时间'),
            'updated_at' => $this->integer()->defaultValue(0)->comment('更新时间'),
        ]);
    }

    public function safeDown()
    {
        $this->createDb();
        $this->dropTable('{{%wechat_payinfo}}');
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m180328_030052_create_wechat_payinfo cannot be reverted.\n";

        return false;
    }
    */
}
